<?php View::render('admin/layouts/meta'); ?>
<link rel="stylesheet" type="text/css" href="<?php echo Router::getBaseUrl();?>/assets/js/webuploader.css" />
<body>
<article class="page-container">
	<form action="" method="post" class="form form-horizontal" id="form-member-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>节点名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" name="name" value="<?php echo $node_info?$node_info['name']:'';?>" />
			</div>
		</div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>上级节点：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
				<select class="select" size="1" name="pid">
                    <option value="0">顶级分类</option>
                    <?php if($node_list){ foreach ($node_list as $row){?>
                    <option value="<?php echo $row['id'];?>" <?php echo $node_info&&$node_info['pid']==$row['id']?'selected=selected':'';?>><?php echo $row['name'];?></option>
                    <?php if($row['child']){ foreach ($row['child'] as $item){?>
                    <option value="<?php echo $item['id'];?>" <?php echo $node_info&&$node_info['pid']==$item['id']?'selected=selected':'';?>><?php echo '|----'.$item['name'];?></option>
                    <?php }}}}?>
				</select>
				</span> 
            </div>
		</div>
        <div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">URL路径：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" name="url_path" value="<?php echo $node_info?$node_info['url_path']:'';?>" />
			</div>
		</div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否显示：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <label><input type="radio" name="is_show" value="0" <?php echo $node_info&&$node_info['is_show']==0?'checked':'';?>> 否 </label>
                <label><input type="radio" name="is_show" value="1" <?php echo $node_info&&$node_info['is_show']==1?'checked':'checked';?>> 是 </label>
            </div>
		</div>
        <div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">图标：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" name="icon" value="<?php echo $node_info?$node_info['icon']:'';?>" />
			</div>
		</div>
        <div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">排序：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" name="sort" value="<?php echo $node_info?$node_info['sort']:0;?>" />
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input type="hidden" name="node_id" value="<?php echo $node_info?$node_info['id']:0;?>" />
                <input class="btn btn-primary radius" type="button" id="j_submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>
</body>
<?php View::render('admin/layouts/footer'); ?>
<script type="text/javascript" src="<?php echo Router::getBaseUrl();?>/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="<?php echo Router::getBaseUrl();?>/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="<?php echo Router::getBaseUrl();?>/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="<?php echo Router::getBaseUrl();?>/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="<?php echo Router::getBaseUrl();?>/assets/js/webuploader.min.js"></script>
<script type="text/javascript">
$(function(){
  $('#j_submit').click(function () {
    var $btn = $(this)
    $btn.button('loading');
    $.post('/admin_admin/node_edit', $('form').serialize(), function (result) {
        if (result.status == 200) {
            layer.msg(result.msg, {
                icon: 1, //0-6
                //anim:2,
                skin: 'u-msg',
                time: 1200,
            },function(){
                var index = parent.layer.getFrameIndex(window.name); 
                parent.layer.close(index);
                parent.window.location.href=parent.window.location.href;
            });

        }else{
            layer.msg(result.msg, {
                icon: 0, //0-6
                //anim:2,
                skin: 'u-msg',
                time: 3000,
            }, function () {
                //do things
            });
        }
        $btn.button('reset');
    }, 'json');
    return;
});
});
</script>
</html>